This page last changed on Jan 26, 2009 by stepheneb.

When I import the projects after making a new Eclipse workspace the phet projects have different names then they do in my long-time Eclipse workspace.

In order to get otrunk-cck to compile I changed the project and jar dependencies to use the names Eclipse gives these projects by default when importing them.

These changes are checked into the 'default-project-names' branch in the gitorious clone of concord-projects-common (which has the name otrunk-examples in it's path).

http://gitorious.org/projects/otrunk-examples/repos/mainline/logs/default-project-names

You can view the diffs at the url above – or if you add the gitorious public repo as a remote to your own git-svn clone of concord-projects-common and then fetch that branch you can examine and test the changes locally.

These instructions assume:

  1. You already have a git-svn clone of the concord-projects-common repo.
  2. You've followed the instructions in the previous email about using the Ruby scripts to help setup the new Eclipse workspace.
  3. You've registered at http://gitorious.org, uploaded your public key, told me your username and I've added you as a committer to: http://gitorious.org/projects/otrunk-examples

You don't need to be a committer to read the gitorious repo but by being a committer we can more easily share branches in one public repo.

Now cd to your git clone and make sure you are in the master branch:

[concord-projects-common.svn.git (master)]$ git remote add gitorious git@gitorious.org:otrunk-examples/mainline.git
  • If you are not a committer to the gitourious repo use this form of url when you add the repo:
[concord-projects-common.svn.git (master)]$ git remote add gitorious git://gitorious.org/otrunk-examples/mainline.git

Now synch your local repo with whatever changes are in the gitorious clone:

[concord-projects-common.svn.git (master)]$ git fetch gitorious

This should take very little time because git can easily tell that the content you already have that was cloned from the svn repo doesn't need to be transferred from the gitorious repo. Theonly content that should be transferred is the data in the new branch I just created.

Display the diff between the master branch (tracking SVN head) and the new branch I pushed with the phet and otrunk-cck .classpath changes.

[concord-projects-common.svn.git (master)]$ git diff default-project-names

If you want to examine this branch in Eclipse check it out into your working dir:

[concord-projects-common.svn.git (master)]$ git checkout -b default-project-names gitorious/default-project-names

This creates a new local branch in your git repo called default-project-names that starts at the same commit tree as the remote gitorious/default-project-names (which you also have in your local git repo). In addition it makes any changes necessary to bring your working dir in line with the default-project-names branch.

When I list ALL my branches like this:

[concord-projects-common.svn.git (default-project-names)]$ git branch -a
* default-project-names
  master
  gitorious/default-project-names
  gitorious/master
  svn/trunk

I see two regular local branches:

  • default-project-names: I'm on this branch (checked out into the working dir)
  • master (my local branch that references the remote branch svn/trunk)

I also see three remote branches (all the content in these branches also exists locally):

  • svn/trunk (this actually tracks projects/trunk/common/ in the svn repo)
  • gitorious/default-project-names (and the two branches at gitorious)
  • gitorious/master

--------

A practical example of this workflow.

People more experienced than I am at git almost always start any work by branching first – I often forget this.

I made a few changes to .classpath files that were not a problem to check-in to subversion. See:

Then to get otrunk-cck working I made more extensive changes. About half way through I realized that these would be inappropriate to check back in to the main svn repo without getting a better idea of what the right changes should be – but I finished the changes anyway and saved them.

Now otrunk-cck was compiling properly (and all the phet projects it depended on) but all these changes were in files tracked by the repo in my working dir.

In order to make a new branch with these changes I temporarily 'stashed' all the changes to all files tracked by the repo:

[concord-projects-common.svn.git (master)]$ git stash
Saved working directory and index state "WIP on master: 767a06e... fix spelling mistake"
HEAD is now at 767a06e fix spelling mistake
(To restore them type "git stash apply")

Then I created and checked out a new branch named default-project-names

[concord-projects-common.svn.git (master)]$ git checkout -b default-project-names
Switched to a new branch "default-project-names"

Then I pulled all the changes I had just stashed back into the working directory for the default-project-names branch:

[concord-projects-common.svn.git (default-project-names)]$ git stash apply
# On branch default-project-names
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   java/dev-tools/jira-linked-issues-plugin/.project
#	modified:   java/dev-tools/jira-linked-issues-plugin/pom.xml
#	modified:   java/otrunk/otrunk-cck/.classpath
#	modified:   java/otrunk/otrunk-ide/.classpath
#	modified:   java/otrunk/otrunk-jackrabbit/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/jfreechart-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/phetcommon/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/piccolo-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/service-manager/.classpath
#	modified:   java/thirdparty/phet-simulations-java/simulations/cck/.classpath

I first made two separate commits:

[concord-projects-common.svn.git (default-project-names)]$ git commit java/otrunk/otrunk-ide/.classpath -m 'remove reference to src/ folder'
[default-project-names]: created 25479f8: "remove reference to src/ folder"
 1 files changed, 0 insertions(+), 1 deletions(-)

[concord-projects-common.svn.git (default-project-names)]$ git commit java/otrunk/otrunk-jackrabbit/.classpath -m 'remove reference to src/test/java folder'
[default-project-names]: created d829aa8: "remove reference to src/test/java folder"
 1 files changed, 0 insertions(+), 1 deletions(-)

Remember – these are commits to my local repo – nothing has been sent to the svn or gitorious repos.

Then I displayed just the list of files that still have changes AND are tracked by the repo:

[concord-projects-common.svn.git (default-project-names)]$ git status -uno
# On branch default-project-names
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   java/dev-tools/jira-linked-issues-plugin/.project
#	modified:   java/dev-tools/jira-linked-issues-plugin/pom.xml
#	modified:   java/otrunk/otrunk-cck/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/jfreechart-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/phetcommon/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/piccolo-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/service-manager/.classpath
#	modified:   java/thirdparty/phet-simulations-java/simulations/cck/.classpath

I decided to throw away my changes to the jira-linked-issues-plugin project (I don't even need this project).
A simple way to revert a few changes in the working dir is to just checkout the file again:

[concord-projects-common.svn.git (default-project-names)]$ git co java/dev-tools/jira-linked-issues-plugin/.project
[concord-projects-common.svn.git (default-project-names)]$ git co java/dev-tools/jira-linked-issues-plugin/pom.xml

Then I checked again what changes were left:

[concord-projects-common.svn.git (default-project-names)]$ git status -uno
# On branch default-project-names
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   java/otrunk/otrunk-cck/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/jfreechart-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/phetcommon/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/piccolo-phet/.classpath
#	modified:   java/thirdparty/phet-simulations-java/common/service-manager/.classpath
#	modified:   java/thirdparty/phet-simulations-java/simulations/cck/.classpath

I decided all of these could go under the same commit message – using the -a option included
all the tracked and changed files that were left in this commit.

[concord-projects-common.svn.git (default-project-names)]$ git commit -a -m 'fix jar and project refs for phet to use default names/paths'
[default-project-names]: created 4e7dea7: "fix jar and project refs for phet to use default names/paths"
 6 files changed, 22 insertions(+), 22 deletions(-)

There were no more changed and tracked files so I made a new remote branch on gitorious that tracks this local branch:

[concord-projects-common.svn.git (default-project-names)]$ git push gitorious default-project-names 
Counting objects: 54, done.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (32/32), 2.64 KiB, done.
Total 32 (delta 28), reused 0 (delta 0)
To git@gitorious.org:otrunk-examples/mainline.git
 * [new branch]      default-project-names -> default-project-names
=> Syncing Gitorious... [OK]

The next day I discovered the problem with the project names. When Eclipse imports a project contained in a normal dir it initializes the name based on the value in the .project file. However when Eclipse imports a project through a sym-linked directory this does not happen. Instead the directory name is used for the project name.

After fixing and refactoring the ruby scripts flatten_projects.rb and create_workingsets.rb to get around this problem I didn't need the default_project_names branch anymore.

However there were two commits on that branch before the one where the project names were changed and I need those.

From the master branch I listed the log of commits on the default-project-names branch:

[concord-projects-common.svn.git (master)]$ git log default-project-names 
commit 0ba5d068bd7bdb6b3e8de75a3a493c712a244256
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Sun Jan 25 18:50:52 2009 -0500

    fix jar and project refs for phet to use default names/paths

commit c1e8f3339649ae3e29e2bee7aff21928cd17c7e8
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Sun Jan 25 18:48:32 2009 -0500

    remove reference to src/test/java folder

commit c0148d62f4ec7aef17da6ff30b6fa7aec4ce7b4a
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Sun Jan 25 18:47:41 2009 -0500

    remove reference to src/ folder

commit 5df819dba4e6e5d7159ee24761e507d5e3a8cc20
Author: qxie <qxie@6e01202a-0783-4428-890a-84243c50cc2b>
Date:   Mon Jan 26 12:37:39 2009 +0000

    git-svn-id: https://svn.concord.org/svn/projects/trunk/common@16807 6e01202a-0783-4428-890a-84243c50cc2b

commit a44ef5cb478b85103d30309e3880c289649b38ad
Author: sbannasch <sbannasch@6e01202a-0783-4428-890a-84243c50cc2b>
Date:   Mon Jan 26 07:59:18 2009 +0000

    add Elclipse build products to .gitignore
    
    git-svn-id: https://svn.concord.org/svn/projects/trunk/common@16806 6e01202a-0783-4428-890a-84243c50cc2b

commit 767a06e4528a686880d4b838387710a914f8e53e
Author: sbannasch <sbannasch@6e01202a-0783-4428-890a-84243c50cc2b>
Date:   Sun Jan 25 18:41:54 2009 +0000

    fix spelling mistake
    
    git-svn-id: https://svn.concord.org/svn/projects/trunk/common@16805 6e01202a-0783-4428-890a-84243c50cc2b

commit a5fccf1051c3a9c585005cb35787ccb97e7f450c

I used git cherry-pick to copy the second and third commits in that list into the master branch.

When specifying a commit you only need to specify enough of the SHA1 hash so that the reference is unambiguous.

[concord-projects-common.svn.git (master)]$ git cherry-pick c0148d62f4ec7aef17d
Finished one cherry-pick.
[master]: created aa2fd60: "remove reference to src/ folder"
 1 files changed, 0 insertions(+), 1 deletions(-)
 
[concord-projects-common.svn.git (master)]$ git cherry-pick c1e8f3339649ae3
Finished one cherry-pick.
[master]: created 7bb29c8: "remove reference to src/test/java folder"
 1 files changed, 0 insertions(+), 1 deletions(-)

Checking the status of the master branch shows that I still need to commit the changes in the ruby scripts:

[concord-projects-common.svn.git (master)]$ git status -uno
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   create_workingsets.rb
#	modified:   flatten_projects.rb
#
no changes added to commit (use "git add" and/or "git commit -a")

I used the -a option with git commit to commit all the tracked-changed files in one commit:

[concord-projects-common.svn.git (master)]$ git commit -a
[master]: created 672d15c: "use Eclipse project name for sym-linked directories"
 2 files changed, 58 insertions(+), 37 deletions(-)
 rewrite create_workingsets.rb (70%)

Now the log for the master branch shows my three new local commits:

[concord-projects-common.svn.git (master)]$ git log
commit 672d15c92b48ab549942ea16f89321a3b40cb4bc
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Mon Jan 26 14:43:29 2009 -0500

    use Eclipse project name for sym-linked directories
    
    Also remove projects that aren't normally needed.
    
    Refactor creation of workingsets.xml so there is
    much less duplicated code.

commit 7bb29c8ffeab2cfcdc38d4c072572b93b13879c2
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Sun Jan 25 18:48:32 2009 -0500

    remove reference to src/test/java folder

commit aa2fd60aba543812beca389002aae3e67522a389
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Sun Jan 25 18:47:41 2009 -0500

    remove reference to src/ folder

commit be63e65defb8baa8b4f1271560e570aafa6f1813
Author: Stephen Bannasch <stephen.bannasch@gmail.com>
Date:   Mon Jan 26 13:35:39 2009 -0500

    remove spurious .project file

commit 5df819dba4e6e5d7159ee24761e507d5e3a8cc20
Author: qxie <qxie@6e01202a-0783-4428-890a-84243c50cc2b>
Date:   Mon Jan 26 12:37:39 2009 +0000

    git-svn-id: https://svn.concord.org/svn/projects/trunk/common@16807 6e01202a-0783-4428-890a-84243c50cc2b

commit a44ef5cb478b85103d30309e3880c289649b38ad
Author: sbannasch <sbannasch@6e01202a-0783-4428-890a-84243c50cc2b>
Date:   Mon Jan 26 07:59:18 2009 +0000

    add Elclipse build products to .gitignore

I use git svn rebase before committing to svn to do two things:

  • rebase does a merge so if there were conflicts I'd be notified and would then first resolve them.
  • rebase also brings my commits forward so when I commit them the order will be after the most recent commits.
[concord-projects-common.svn.git (master)]$ git svn rebase
	M	java/simulations/biologica/src/org/concord/biologica/test/EnvironmentViewTest.java
r16809 = 682afe69956538541bc450d24f8c53d4505656e5 (svn/trunk)
	M	java/otrunk/otrunk-examples/UDL/udl-friction-34.otml
	M	java/otrunk/otrunk-examples/UDL/udl-friction-56.otml
	M	java/otrunk/otrunk-examples/UDL/udl-electricity-56.otml
	M	java/otrunk/otrunk-examples/UDL/udl-plants-34.otml
r16810 = 5eec87610ad8eb1350f56786d2a11e7a6f18cda0 (svn/trunk)
	M	java/simulations/qm/src/org/concord/qm1d/MainWindow.java
	M	java/simulations/qm/src/org/concord/qm1d/QuarticDoubleWell.java
	M	java/simulations/qm/src/org/concord/qm1d/Scripter.java
r16814 = 8db163adcb013953ee3ce503ed2ea2af0ce2c7dd (svn/trunk)
	M	java/otrunk/otrunk-examples/UDL/udl-friction-34.otml
	M	java/otrunk/otrunk-examples/UDL/udl-friction-56.otml
	M	java/otrunk/otrunk-examples/UDL/udl-electricity-56.otml
	M	java/otrunk/otrunk-examples/UDL/udl-plants-34.otml
r16815 = 4a212914ee233643a37bb5853d38a9ed5107dd1b (svn/trunk)
	M	java/otrunk/otrunk-biologica/src/main/java/org/concord/otrunk/biologica/ui/OTOrganismEditView.java
r16816 = 48bfa09b9502cf07cf51ecf5f99f838a98bf46ca (svn/trunk)
	M	java/otrunk/otrunk-ui/src/main/java/org/concord/otrunk/ui/swing/OTSelectCreateEditView.java
	M	java/otrunk/otrunk-ui/src/main/java/org/concord/otrunk/ui/swing/CustomDetailListCellRenderer.java
r16817 = 76585929787ffb4dd89f942138baf0dd82d34766 (svn/trunk)
First, rewinding head to replay your work on top of it...
Applying: remove spurious .project file
Applying: remove reference to src/ folder
Applying: remove reference to src/test/java folder
Applying: use Eclipse project name for sym-linked directories

There were no conflicts so I commit my local commits back to svn:

[concord-projects-common.svn.git (master)]$ git svn dcommit
Committing to https://svn.concord.org/svn/projects/trunk/common ...
	D	java/math/rtt-applets/src/org/concord/rttapplets/localization/.project
Committed r16819
	D	java/math/rtt-applets/src/org/concord/rttapplets/localization/.project
r16819 = d2e8cd4196eecca4a25a91b6209d10f5ace2625d (svn/trunk)
No changes between current HEAD and refs/remotes/svn/trunk
Resetting to the latest refs/remotes/svn/trunk
create_workingsets.rb: locally modified
flatten_projects.rb: locally modified
java/otrunk/otrunk-ide/.classpath: locally modified
java/otrunk/otrunk-jackrabbit/.classpath: locally modified
	M	java/otrunk/otrunk-ide/.classpath
Committed r16820
	M	java/otrunk/otrunk-ide/.classpath
r16820 = 7ab5cd9a3bc39b6950d084c3e252e3e73d47a7f9 (svn/trunk)
No changes between current HEAD and refs/remotes/svn/trunk
Resetting to the latest refs/remotes/svn/trunk
create_workingsets.rb: locally modified
flatten_projects.rb: locally modified
java/otrunk/otrunk-jackrabbit/.classpath: locally modified
	M	java/otrunk/otrunk-jackrabbit/.classpath
Committed r16821
	M	java/otrunk/otrunk-jackrabbit/.classpath
r16821 = 0dd64affd1f9c4810a5ba13faed12612cf1b3cd8 (svn/trunk)
No changes between current HEAD and refs/remotes/svn/trunk
Resetting to the latest refs/remotes/svn/trunk
create_workingsets.rb: locally modified
flatten_projects.rb: locally modified
	M	create_workingsets.rb
	M	flatten_projects.rb
Committed r16822
	M	create_workingsets.rb
	M	flatten_projects.rb
r16822 = 9beaea67d40a9d2cb9fb010320c77a08d9a18dee (svn/trunk)
No changes between current HEAD and refs/remotes/svn/trunk
Resetting to the latest refs/remotes/svn/trunk

Running git status shows there are no more tracked-changed files.

[concord-projects-common.svn.git (master)]$ git status -uno
# On branch master
nothing to commit (use -u to show untracked files)

At this point I can delete the remote branch I setup on the gitorious repository. I list the remote branches to remember the names:

[concord-projects-common.svn.git (master)]$ git branch -r
  gitorious/default-project-names
  gitorious/master
  svn/trunk

Actually deleting the remote branch:

[concord-projects-common.svn.git (master)]$ git push gitorious :heads/default-project-names
To git@gitorious.org:otrunk-examples/mainline.git
 - [deleted]         default-project-names
=> Syncing Gitorious... [OK]

I still have my local branch to delete:

[concord-projects-common.svn.git (master)]$ git branch
  default-project-names
* master

I first used the standard branch delete command and am warned that default-project-names branch has commits (just one) that are ahead of my current branch:

[concord-projects-common.svn.git (master)]$ git branch -d default-project-names
error: The branch 'default-project-names' is not an ancestor of your current HEAD.
If you are sure you want to delete it, run 'git branch -D default-project-names'.

I used the option -D to force the deletion:

[concord-projects-common.svn.git (master)]$ git branch -D default-project-names
Deleted branch default-project-names (0ba5d06).
Document generated by Confluence on Jan 27, 2014 16:56